<div class="page-header clearfix">
    <div class="pull-left">
        <h4 class="mt-0 mb-5">菜单修改</h4>
        <ol class="breadcrumb mb-0">
            <li><a href="javascript:;">你可以对商品标签进行菜单修改</a></li>
        </ol>
    </div>
</div>
<div class="main-content container-fluid">
    <div class="widget">
        <div class="widget-heading">
            <h3 class="widget-title">菜单修改</h3>
        </div>
        <div class="widget-body">
            <form id="form-vertical" method="post" action="{:url('admin/menu/edit')}" novalidate="novalidate">
                <div class="form-group">
                    <label>菜单名称</label>
                    <input value="{$shop->name}" type="text" name="name" placeholder="请输入菜单名称" data-messages="请输入菜单名称" data-rule-required="true" class="form-control">
                </div>
                <div class="form-group">
                    <label>英文标识</label>
                    <input value="{$shop->en_name}" type="text" name="en_name" placeholder="请输入英文标识" data-messages="请输入英文标识" data-rule-required="true" class="form-control">
                </div>
                <div class="form-group">
                    <label>链接</label>
                    <input value="{$shop->url}" type="text" name="url" placeholder="请输入链接" data-messages="请输入链接" data-rule-required="true" class="form-control">
                </div>
                <input type="hidden" name="type" value="save">
                <input type="hidden" name="id" value="{$shop->id}">
                <button type="submit" name="btnSubmit" class="btn btn-raised btn-black btn-block">
                    修改菜单
                </button>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript" src="/static/admin/plugins/jquery-validation/dist/jquery.validate.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/jquery-validation/dist/additional-methods.min.js"></script>
<script>
    $(function () {



        $("#form-vertical").validate({
            highlight:function(r){
                $(r).closest(".form-group").addClass("has-error")
            },
            rules:{
                name:{
                    required : true
                },
                en_name:{
                    required : true
                }
            },
            messages:{
                name:{
                    required : '不能为空'
                },
                en_name:{
                    required : '不能为空'
                },
                url:{
                    required : '不能为空'
                }
            },
            unhighlight:function(r){
                $(r).closest(".form-group").removeClass("has-error")
            },
            errorElement:"span",
            errorClass:"help-block",
            errorPlacement:function(r,e){
                e.parent(".input-group").length?r.insertAfter(e.parent()):e.parent("label").length?r.insertBefore(e.parent()):r.insertAfter(e)
            },
            submitHandler: function (form) {
                Pace.restart();
                ajax.formSubmit('#form-vertical',function (data) {
                    if(data.err){
                        layer.msg(data.msg,{
                            icon:2,
                            time:1000
                        });
                        return false;
                    }
                    layer.msg(data.msg,{
                        icon:1,
                        time:1000
                    });
                    setTimeout(function () {
                        $('a[_href="{:url('admin/menu/index')}"]').click();
                    },1000);
                });
                return false;
            }
        });
    });
</script>